﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DataAccess;
using Common;

namespace Business
{
    public class CommentBll
    {
        private CommentDao _commentDao;
        /// <summary>
        /// Initializes a new instance of the <see cref="CommentBll"/> class.
        /// </summary>
        public CommentBll()
        {
            _commentDao = new CommentDao();
        }

        #region Methods
        /// <summary>
        /// Views all comments.
        /// </summary>
        /// <param name="postId">The post id.</param>
        /// <returns></returns>
        public DataTable ViewAllComments(int postId)
        {
            try
            {
                return _commentDao.ViewAllComments(postId);
            }
            catch (Exception)
            {
                
                throw;
            }
        }
        /// <summary>
        /// Adds the comment.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="comment">The comment.</param>
        /// <param name="date">The date.</param>
        /// <param name="postId">The post id.</param>
        /// <returns></returns>
        public bool AddComment(string name, string comment, DateTime date, int postId)
        {
            try
            {
                int result = _commentDao.AddComment(name, comment, date, postId);
                return (result != 0 );
            }
            catch (Exception)
            {
                
                throw;
            }
        }
        /// <summary>
        /// Deletes the comment.
        /// </summary>
        /// <param name="postId">The post id.</param>
        /// <returns></returns>
        public bool DeleteCommentByPostId(int postId)
        {
            try
            {
                int result = _commentDao.DeleteCommentByPostId(postId);
                return (result != 0);
            }
            catch (Exception)
            {
                
                throw;
            }
        }
        #endregion
    }
}
